package com.lyc.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @author ：Xiaochen
 * @date ：Created in 2022/11/18 20:41
 * @description：
 * @modified By：
 * @version:
 */
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket docket(){
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                //组名
                .groupName("qy158")
                //API信息
                .apiInfo(getinfo())
                //选择哪些生成api接口---根据请求路径选择  (2)根据包名选择
                .select()
                //根据请求路径选择
                //.paths(Predicates.and(PathSelectors.regex("/api/.*")))
                //根据包名选择
                .apis(RequestHandlerSelectors.basePackage("com.lyc.controller"))
                .build()
                ;
        return docket;
    }

    private ApiInfo getinfo(){
         Contact DEFAULT_CONTACT = new Contact("刘延臣2", "http://www.huya.com", "liu@qq.com");
         ApiInfo DEFAULT = new ApiInfo("MrLiu2 API", "MrLiu API", "2.0", "http://www.huya.com",
                DEFAULT_CONTACT, "金钱有限公司2", "http://www.huya.com", new ArrayList<VendorExtension>());
         return DEFAULT;
    }
}